/*
 * All rights Reserved, Designed By cloudland Copyright(C) 2010-2014
 *
 * fileName:  ContextException.java
 * author:  lei
 * Company:  Cloudland Studio
 * Createdate:  2013-9-15 上午11:31:20
 *   
 * Modification  History:
 *     Date           Author        Version        
 * -------------------------------------------
 * 2013-9-15          Lei            1.0        
 *
 * Why & What is modified:
 * 1.0: 文件创建
 */
package org.cloudland.commercial.masterdata.exception;

import java.util.Locale;
import java.util.ResourceBundle;

import org.cloudland.core.exception.IException;

 /**
 * <pre> 
 * TODO 请充分描述该类提供的作用, 或与其他类会有关联的使用。
 * 使用 {@link java.lang.Object#toString()}, 或者 {@link java.lang.Character Character} 等标签
 * </pre>
 * @ClassName  ContextException
 * @author  lei
 * @version  %I%, %G%
 * @see  
 * @since   JDK1.6
 *
 */
public class MasterDataException extends RuntimeException implements IException {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 1L;

	/**
     * 加载错误信息描述的资源文件
     */
    private static ResourceBundle BUNDEL_CONFIG = null;
	
    static {
    	StringBuffer classPath = new StringBuffer(MasterDataException.class.getPackage().getName());
    	classPath.append(".masterdata_exp");
    	BUNDEL_CONFIG = ResourceBundle.getBundle(classPath.toString(), Locale.getDefault(), MasterDataException.class.getClassLoader());
    }
    
    /**
     * code 错误编号
     */
    private String code;
    
    
    /**
     * <pre>
     * 通过错误编号构建异常对象。
     * </pre>
     *
     * @param code  错误编号
     */
    public MasterDataException(String code) {
    	super(BUNDEL_CONFIG.getString(code));
    	this.code = code;
    }
    
    /**
     * <pre>
     * 通过错误编号和错误堆栈构建异常对象。
     * </pre>
     *
     * @param code
     * @param cause   
     */
    public MasterDataException(String code, Throwable cause) {
    	super(BUNDEL_CONFIG.getString(code), cause);
    	this.code = code;
    }
    
	/**
	 * @return
	 */
	public String getCode() {
		return code;
	}
	
	/**
	 * @return
	 */
	@Override
	public String getMessage() {
		return super.getMessage();
	}
	
}
